<?php
/**
 *
 * User: zhaomeng1
 * Date: 2019/5/15
 * Time: 4:19 PM
 *
 *
 *
 * 5月
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */
include "Mysql_model.php";

$redis = new Redis();

$redis->connect("172.17.0.8",6379);

$redis->auth('ADMINadmin');


$redis_name='miaosha';

$my =  mysql::getIns();



while (1){

    $user = $redis->lPop($redis_name);

    if(!$user || $user=='nli'){

        sleep (2);

        continue;
    }

    $user_arr = explode ("%",$user);
    $insert_str = "insert into redis_queue(uid,time_stamp) values('$user_arr[0]' ,'$user_arr[1]')";

    $res = $my->query ($insert_str);

    if($res){
        $redis->rPush ($redis_name,$user);
    }
    sleep (2);
}

$redis->close ();
